<template>
    <div class="newsinfo-container">
            新闻详情
            {{$route.params.id}}
    </div>
</template>
<script>
import axios  from 'axios'
    export default {
        data(){
            return {
                newsid:this.$route.params.id,
                newsinfo:{}
            }
        },
        methods:{
        },
        mounted(){
            console.log(this.newsid);
            axios.get('src/json/home_neswlist.json', {} , {emulateJSON: true}).then((response) => {
                this.home_newslist = response.data.data;
                response.data.data.forEach((item)=>{
                    if(this.newsid === item.id){
                        this.newsinfo = item;//concat数组拼接
                        console.log("成功");
                        return false;
                    }else{
                        console.log("失败");
                    }
                })
                console.log(this.newsinfo);
                // console.log(this.home_newslist);
            }).catch(function (error) {
                console.log(error);
            })
        }
        
    }
</script>
<style lang="less" scoped>
</style>
